<p class="Paragraph"><help:paragraphinfo state="U" number="2"/>Calls a subroutine that is indicated by a label from a subroutine or a function. The statements following the label are executed until the next Return statement. Afterwards, the program continues with the statement that follows the <span style="font-weight:bold;">GoSub </span>statement.</p>
<p class="Paragraph"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/>The <span class="T1">GoSub</span> statement calls a local subroutine indicated by a label from within a subroutine or a function. The name of the label must end with a colon (":").</p>
<p class="TextInTable"><draw:image draw:name="Icon0" svg:desc="This icon marks text containing important information on data and system security." svg:pixelx="32" svg:pixely="32" svg:width="0.847cm" svg:height="0.847cm" xlink:href="65640" draw:filter-name="" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
<p class="TextInTable"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/>If the program encounters a Return statement not preceded by <span class="T1">GoSub</span>, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic returns an error message. Use <span class="T1"><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>Exit Sub</span> or <span class="T1">Exit Function</span> to ensure that the program leaves a Sub or Function before reaching the next Return statement.</p>
</span></th></tr></table>
<p class="Paragraph"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>The following example demonstrates the use of <span class="T1">GoSub</span> and <span class="T1">Return</span>. By executing a program section twice, the program calculates the square root of two numbers that are entered by the user.</p>